﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OUSMS.AppLogic.DataAccessLayer;
using OUSMS.AppLogic.BusinessLogicLayer;
using System.Web.ModelBinding;
using OUSMS.Helpers;
namespace OUSMS
{
    public partial class MotionHistoryList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        // 返回类型可以更改为 IEnumerable，但是为了支持
        // 分页和排序，必须添加以下参数:
        //     int maximumRows
        //     int startRowIndex
        //     out int totalRowCount
        //     string sortByExpression
        public IQueryable<Motions> MotionsGridView_GetData(int maximumRows, int startRowIndex, out int totalRowCount, string sortByExpression)
        {
            MotionsBLL motionsBLL = new MotionsBLL();
            UsersBLL usersBLL = new UsersBLL();
            Users userEntity = usersBLL.GetUserByLoginName(User.Identity.Name);
            string roleType = "";
            switch (Request.QueryString["Role"])
            {
                case "1":
                    roleType = "评审专家";
                    break;
                case "2":
                    roleType = "部门负责人";
                    break;
                case "3":
                    roleType = "校领导";
                    break;
            }
            return motionsBLL.GetMotionHistoryList(maximumRows, startRowIndex, out totalRowCount, sortByExpression, roleType, userEntity.ID);
        }

        protected void MotionsGridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label indexLbl = e.Row.FindControl("indexLbl") as Label;
                indexLbl.Text = (e.Row.RowIndex + 1).ToString();
            }
        }
    }
}